package com.atguigu.oss.controller;

import com.atguigu.commonutils.Result;
import com.atguigu.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/eduoss/fileoss")
public class OssController {

    @Autowired
    private OssService ossService;

    //头像文件的上传
    @PostMapping("upload")
    public Result uploadOssAvatar(MultipartFile file){//MultipartFile获取到上传的文件
        //调用Service层上传文件的方法,返回上传文件的路径
        String url= ossService.uploadFileAvatar(file);
        return Result.ok().data("url",url);
    }

}
